<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<title>优酷无线统计平台</title>
		
		<!--                       CSS                       -->
	  
		<!-- Reset Stylesheet -->
		<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />
	  
				
		<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
		<link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" />	
		
		<link rel="stylesheet" href="resources/css/glowform.css" type="text/css" media="screen" />	
		

		<!--                       Javascripts                       -->
	  
		<!-- jQuery -->
		<script type="text/javascript" src="resources/scripts/jquery-1.7.1.min.js"></script>
		
		<!-- jQuery Configuration -->
		<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
		
		<!-- Facebox jQuery Plugin -->
		<script type="text/javascript" src="resources/scripts/facebox.js"></script>
		
		<!-- jQuery WYSIWYG Plugin -->
		<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
		
		<script type="text/javascript" scr="resources/pagejs/util.js"></script>
		<!-- Internet Explorer .png-fix -->
		
		<!--[if IE 6]>
			<script type="text/javascript" src="resources/scripts/DD_belatedPNG_0.0.7a.js"></script>
			<script type="text/javascript">
				DD_belatedPNG.fix('.png_bg, img, li');
			</script>
		<![endif]-->
		
		<script>
			function setCookie(name, value, expires, path, domain, secure) { 
				var curcookie = name + "=" + encodeURI(value) 
				+((expires) ? ";expires=" + expires.toGMTString() : "") 
				+((path) ? ";path=" + path : "") 
				+((domain) ? ";domain=" + domain : "") 
				+((secure) ? ";secure" : ""); 
				document.cookie = curcookie; 
			} 

			function getCookie(name) { 
				if(document.cookie.length > 0) { 
					start = document.cookie.indexOf(name + "="); 
					if( start != -1) { 
						start = start + name.length + 1; 
						end = document.cookie.indexOf(";",start); 
						if( end == -1) { 
							end = document.cookie.length; 
						} 
						return decodeURI(document.cookie.substring(start,end)); 
					} 
					
				} 
				return ""; 
			} 

			function loginCheck(uname, pwd) { 
				var name = $("#uname").attr("value"); 
				var pass = encodeURIComponent($("#pwd").attr("value")); 
				$.ajax({
					type: "GET",
					url: "/client/userPamLogin?uname="+name+"&pwd="+pass,
					dataType : "jsonp",
					jsonnp: "callback",
					success: doLoginCheck
				});
			} 

			function doLoginCheck(data) {
				if( data.status == "success" ) { 
					var now = new Date(); 
					now.setDate( now.getDate() + 90); 
					setCookie("uname",data.results.username,now); 
					setCookie("uid",data.results.userid,now); 
					setCookie("pwd",$("#pwd").attr("value"), now);
					window.location.href = "index.html"; 
				} 
				else {
					$("#errorMsg").show();
					$("#uname").val("");
					$("#pwd").val("");
				}
			}

			function userlogin() { 
				var login = getCookie("uname"); 
				if ( login != null && login != "" ) { 

					window.location.href = "index.html"; 
				} 
			} 

			userlogin(); 


			$(function(){
			  var $form_inputs =   $('form input');
			  var $rainbow_and_border = $('.rain, .border');
			  /* Used to provide loping animations in fallback mode */
			  $form_inputs.bind('focus', function(){
				$rainbow_and_border.addClass('end').removeClass('unfocus start');
			  });
			  $form_inputs.bind('blur', function(){
				$rainbow_and_border.addClass('unfocus start').removeClass('end');
			  });
			  $form_inputs.first().delay(800).queue(function() {
				$(this).focus();
			  });
			});

			function KeyDown()
			{
			　　if (event.keyCode == 13)
			　　{
					loginCheck();
			　　}
			}

		</script>




	</head>
  
	<body id="login">
		
		<div id="login-wrapper" class="png_bg">
			<div id="login-top" class="logintop">
				<div id="loginHeader" class="loginheader">
					<!-- Logo (221px width) -->
					<img id="logo" src="resources/images/logo.png" alt="优酷无线统计" />
				</div>
			</div> <!-- End #logn-top -->
			
				<div id="errorMsg" class="notification information png_bg"  style="display:none">
					<div>
						用户名或密码不正确。
					</div>
				</div>

				
				<div class="rain">
					<div class="border start">
						<form>
							<label for="email">用户名</label>
							<input id="uname" class="text-input" type="text" onkeydown="KeyDown()" />
							<label for="pass">密码</label>
							<input id="pwd" class="text-input" type="password" onkeydown="KeyDown()" />
							<input class="button" type="button" onclick="loginCheck()" value="登陆" />
						
						</form>
					</div>
				</div>					
			
		</div> <!-- End #login-wrapper -->
		
  </body>
  </html>
